package export;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;

import jxl.CellView;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import pojo.Company;
import pojo.SelectedItems;
import pojo.TimeNode;
import util.Exportability;

public class ExportabilityImp implements Exportability {

	@Override
	public boolean exportSinglePage(String path, Company company, TimeNode timeNode) {
		try {
			String filePath = path;
			WritableWorkbook wwb;

			OutputStream os = new FileOutputStream(filePath);
			wwb = Workbook.createWorkbook(os);
			WritableSheet sheet = wwb.createSheet("企业信息格式表", 0);
			if (company.getQiyemingcheng() == null || "".equals(company.getQiyemingcheng())) {

				CellView cellView = new CellView();

				cellView.setSize(4100);
				sheet.setColumnView(0, cellView);
				sheet.setColumnView(1, cellView);
				sheet.setColumnView(2, cellView);
				sheet.setColumnView(3, cellView);
				sheet.setColumnView(4, cellView);
				sheet.setColumnView(5, cellView);
				sheet.setColumnView(6, cellView);
				sheet.setColumnView(7, cellView);
				sheet.setColumnView(8, cellView);
				sheet.setColumnView(9, cellView);
				sheet.setColumnView(10, cellView);
				sheet.setColumnView(11, cellView);
				sheet.setColumnView(12, cellView);
				sheet.setColumnView(13, cellView);

				for (int i = 0; i < 17; i++) {
					sheet.setRowView(i, 540, false);
				}

				Label label;

				jxl.write.NumberFormat nf = new jxl.write.NumberFormat("#,###.00");
				jxl.write.WritableCellFormat wcf = new jxl.write.WritableCellFormat(nf);
				wcf.setAlignment(Alignment.CENTRE);
				wcf.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);

				label = new Label(0, 0, "企业名称", getHeader());
				sheet.addCell(label);

				label = new Label(1, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(2, 0, "建设单位", getHeader());
				sheet.addCell(label);

				label = new Label(3, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(4, 0, "包项目负责人", getHeader());
				sheet.addCell(label);

				label = new Label(5, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(6, 0, "企业联系人", getHeader());
				sheet.addCell(label);

				label = new Label(7, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(8, 0, "联系人电话", getHeader());
				sheet.addCell(label);

				label = new Label(9, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(10, 0, "项目属性", getHeader());
				sheet.addCell(label);

				label = new Label(11, 0, null, getHeader());
				sheet.addCell(label);

				label = new Label(12, 0, "企业分类", getHeader());
				sheet.addCell(label);

				label = new Label(13, 0, null, getHeader());
				sheet.addCell(label);
				// sheet.mergeCells(9, 0, 13, 0);
				// label = new Label(9, 0, null, getHeader());
				// sheet.addCell(label);

				label = new Label(0, 1, "占地", getHeader());
				sheet.addCell(label);

				label = new Label(1, 1, null);
				sheet.addCell(label);

				label = new Label(2, 1, "注册资本", getHeader());
				sheet.addCell(label);

				label = new Label(3, 1, null);
				sheet.addCell(label);

				label = new Label(4, 1, "总投资", getHeader());
				sheet.addCell(label);

				label = new Label(5, 1, null);
				sheet.addCell(label);

				label = new Label(6, 1, "年产值", getHeader());
				sheet.addCell(label);

				label = new Label(7, 1, null);
				sheet.addCell(label);

				label = new Label(8, 1, "用工", getHeader());
				sheet.addCell(label);

				label = new Label(9, 1, null);
				sheet.addCell(label);

				label = new Label(10, 1, "税收", getHeader());
				sheet.addCell(label);

				label = new Label(11, 1, null);
				sheet.addCell(label);

				label = new Label(12, 1, "利润", getHeader());
				sheet.addCell(label);

				label = new Label(13, 1, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 2, 0, 4);
				label = new Label(0, 2, "简介", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 2, 13, 4);
				label = new Label(1, 2, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 5, 0, 7);
				label = new Label(0, 5, "备注", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 5, 13, 7);
				label = new Label(1, 5, null, getHeader());
				sheet.addCell(label);

				label = new Label(2, 8, "注册", getHeader());
				sheet.addCell(label);

				label = new Label(3, 8, "土地预审", getHeader());
				sheet.addCell(label);

				label = new Label(4, 8, "备案", getHeader());
				sheet.addCell(label);

				label = new Label(5, 8, "环评", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 8, 7, 8);
				label = new Label(6, 8, "建设用地规划许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 8, 9, 8);
				label = new Label(8, 8, "建筑工程规划许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 8, 11, 8);
				label = new Label(10, 8, "施工许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 8, 13, 8);
				label = new Label(12, 8, "土地出让合同", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 8, 0, 10);
				label = new Label(0, 8, "手续办理", getHeader());
				sheet.addCell(label);

				label = new Label(1, 8, "条目", getHeader());
				sheet.addCell(label);

				label = new Label(1, 9, "手续文件", getHeader());
				sheet.addCell(label);

				label = new Label(2, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(3, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(4, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(5, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 9, 7, 9);
				label = new Label(6, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 9, 9, 9);
				label = new Label(8, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 9, 11, 9);
				label = new Label(10, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 9, 13, 9);
				label = new Label(12, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(1, 10, "办理时间", getHeader());
				sheet.addCell(label);

				label = new Label(2, 10, null, getHeader());
				sheet.addCell(label);

				label = new Label(3, 10, null, getHeader());
				sheet.addCell(label);

				label = new Label(4, 10, null, getHeader());
				sheet.addCell(label);

				label = new Label(5, 10, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 10, 7, 10);
				label = new Label(6, 10, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 10, 9, 10);
				label = new Label(8, 10, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 10, 11, 10);
				label = new Label(10, 10, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 10, 13, 10);
				label = new Label(12, 10, null, getHeader());
				sheet.addCell(label);

				label = new Label(0, 11, "年度目标", getHeader());
				sheet.addCell(label);

				label = new Label(1, 11, "完成投资", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(2, 11, 7, 11);

				label = new Label(2, 11, null);
				sheet.addCell(label);

				label = new Label(8, 11, "开工面积", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(9, 11, 13, 11);

				label = new Label(9, 11, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 12, 0, 13);
				label = new Label(0, 12, "时间节点", getHeader());
				sheet.addCell(label);

				label = new Label(1, 12, "年份", getHeader());
				sheet.addCell(label);

				for (int i = 1; i <= 12; i++) {
					label = new Label(i + 1, 12, i + "月", getHeader());
					sheet.addCell(label);
				}

				label = new Label(1, 13, null);
				sheet.addCell(label);
				for (int i = 2; i <= 13; i++) {
					label = new Label(i, 13, null, getHeader());
					sheet.addCell(label);
				}

				sheet.mergeCells(0, 14, 0, 16);
				label = new Label(0, 14, "当前进展", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 14, 13, 16);
				label = new Label(1, 14, null, getHeader());
				sheet.addCell(label);

				wwb.write();
				wwb.close();
				os.close();

				return true;
			} else {

				CellView cellView = new CellView();

				CellView cellView2 = new CellView();
				cellView2.setSize(8000);

				cellView.setAutosize(true);
				sheet.setColumnView(0, cellView);
				sheet.setColumnView(1, cellView2);
				sheet.setColumnView(2, cellView2);
				sheet.setColumnView(3, cellView);
				sheet.setColumnView(4, cellView);
				sheet.setColumnView(5, cellView);
				sheet.setColumnView(6, cellView);
				sheet.setColumnView(7, cellView);
				sheet.setColumnView(8, cellView);
				sheet.setColumnView(9, cellView);
				sheet.setColumnView(10, cellView);
				sheet.setColumnView(11, cellView);
				sheet.setColumnView(12, cellView);
				sheet.setColumnView(13, cellView);

				sheet.setRowView(0, 810, false);
				for (int i = 1; i < 17; i++) {
					if (i == 13) {
						sheet.setRowView(i, 810, false);
						continue;
					}
					sheet.setRowView(i, 540, false);
				}

				Label label;

				jxl.write.NumberFormat nf = new jxl.write.NumberFormat("#,###.00"); // 这个格式容易出现数字不能显示出来数字的小bug，一般不用
				jxl.write.WritableCellFormat wcf = new jxl.write.WritableCellFormat(nf);
				wcf.setAlignment(Alignment.CENTRE);
				wcf.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);

				label = new Label(0, 0, "企业名称", getHeader());
				sheet.addCell(label);

				/* label = new Label(1, 0, null, getHeader()); */
				label = new Label(1, 0, company.getQiyemingcheng(), getHeader());
				sheet.addCell(label);

				label = new Label(2, 0, "建设单位", getHeader());
				sheet.addCell(label);

				// label = new Label(3, 0, null, getHeader());
				label = new Label(3, 0, company.getJianshedanwei(), getHeader());
				sheet.addCell(label);

				label = new Label(4, 0, "包项目负责人", getHeader());
				sheet.addCell(label);

				// label = new Label(5, 0, null, getHeader());
				label = new Label(5, 0, company.getBaoxiangmufuzeren(), getHeader());
				sheet.addCell(label);

				label = new Label(6, 0, "企业联系人", getHeader());
				sheet.addCell(label);

				// label = new Label(7, 0, null, getHeader());
				label = new Label(7, 0, company.getQiyelianxiren(), getHeader());
				sheet.addCell(label);

				label = new Label(8, 0, "项目属性", getHeader());
				sheet.addCell(label);

				// sheet.mergeCells(9, 0, 13, 0);
				/* label = new Label(9, 0, null, getHeader()); */
				String xmsx = "";
				for (String s : company.getXiangmushuxing()) {
					xmsx = xmsx.concat((s + " "));
				}
				label = new Label(9, 0, xmsx, getHeader());
				sheet.addCell(label);

				label = new Label(10, 0, "联系人电话", getHeader());
				sheet.addCell(label);

				// sheet.mergeCells(11, 0, 13, 0);
				label = new Label(11, 0, company.getLianxirendianhua(), getHeader());
				sheet.addCell(label);

				label = new Label(12, 0, "企业分类", getHeader());
				sheet.addCell(label);

				String qysx = "";
				for (String s : company.getQiyefenlei()) {
					qysx = qysx.concat((s + " "));
				}
				label = new Label(13, 0, qysx, getHeader());
				sheet.addCell(label);

				label = new Label(0, 1, "占地", getHeader());
				sheet.addCell(label);
		
					label = new Label(1, 1, company.getZhandi(), getHeader());
					sheet.addCell(label);
				
				label = new Label(2, 1, "注册资本", getHeader());
				sheet.addCell(label);
				
					label = new Label(3, 1, company.getZhuceziben(), getHeader());
					sheet.addCell(label);

				label = new Label(4, 1, "总投资", getHeader());
				sheet.addCell(label);

					label = new Label(5, 1, company.getZongtouzi(), getHeader());
					sheet.addCell(label);

				label = new Label(6, 1, "年产值", getHeader());
				sheet.addCell(label);

					label = new Label(7, 1, company.getNianchanzhi(), getHeader());
					sheet.addCell(label);

				label = new Label(8, 1, "用工", getHeader());
				sheet.addCell(label);

					label = new Label(9, 1, company.getYonggong(), getHeader());
					sheet.addCell(label);


				label = new Label(10, 1, "税收", getHeader());
				sheet.addCell(label);

					label = new Label(11, 1, company.getShuishou(), getHeader());
					sheet.addCell(label);

				label = new Label(12, 1, "利润", getHeader());
				sheet.addCell(label);

					label = new Label(13, 1, company.getLirun(), getHeader());
					sheet.addCell(label);

				sheet.mergeCells(0, 2, 0, 4);
				label = new Label(0, 2, "简介", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 2, 13, 4);
				label = new Label(1, 2, company.getJianjie(), getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 5, 0, 7);
				label = new Label(0, 5, "备注", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 5, 13, 7);
				label = new Label(1, 5, company.getBeizhu(), getHeader());
				sheet.addCell(label);

				label = new Label(2, 8, "注册", getHeader());
				sheet.addCell(label);

				label = new Label(3, 8, "土地预审", getHeader());
				sheet.addCell(label);

				label = new Label(4, 8, "备案", getHeader());
				sheet.addCell(label);

				label = new Label(5, 8, "环评", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 8, 7, 8);
				label = new Label(6, 8, "建设用地规划许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 8, 9, 8);
				label = new Label(8, 8, "建筑工程规划许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 8, 11, 8);
				label = new Label(10, 8, "施工许可", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 8, 13, 8);
				label = new Label(12, 8, "土地出让合同", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(0, 8, 0, 10);
				label = new Label(0, 8, "手续办理", getHeader());
				sheet.addCell(label);

				label = new Label(1, 8, "条目", getHeader());
				sheet.addCell(label);

				label = new Label(1, 9, "手续文件", getHeader());
				sheet.addCell(label);

				label = new Label(2, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(3, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(4, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(5, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 9, 7, 9);
				label = new Label(6, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 9, 9, 9);
				label = new Label(8, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 9, 11, 9);
				label = new Label(10, 9, null, getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 9, 13, 9);
				label = new Label(12, 9, null, getHeader());
				sheet.addCell(label);

				label = new Label(1, 10, "办理时间", getHeader());
				sheet.addCell(label);

				label = new Label(2, 10, company.getZhuceshijian(), getHeader());
				sheet.addCell(label);

				label = new Label(3, 10, company.getTudiyushenshijian(), getHeader());
				sheet.addCell(label);

				label = new Label(4, 10, company.getBeianshijian(), getHeader());
				sheet.addCell(label);

				label = new Label(5, 10, company.getHuanpingshijian(), getHeader());
				sheet.addCell(label);

				sheet.mergeCells(6, 10, 7, 10);
				label = new Label(6, 10, company.getJiansheyongdixukeshijian(), getHeader());
				sheet.addCell(label);

				sheet.mergeCells(8, 10, 9, 10);
				label = new Label(8, 10, company.getJianzhugongchengshijian(), getHeader());
				sheet.addCell(label);

				sheet.mergeCells(10, 10, 11, 10);
				label = new Label(10, 10, company.getShigongxukeshijian(), getHeader());
				sheet.addCell(label);

				sheet.mergeCells(12, 10, 13, 10);
				label = new Label(12, 10, company.getTudichuranghetongshijian(), getHeader());
				sheet.addCell(label);

				label = new Label(0, 11, "年度目标", getHeader());
				sheet.addCell(label);

				label = new Label(1, 11, "完成投资", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(2, 11, 7, 11);

					label = new Label(2, 11, company.getWanchengtouzi(), getHeader());
					sheet.addCell(label);

				label = new Label(8, 11, "开工面积", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(9, 11, 13, 11);

					label = new Label(9, 11, company.getKaigongmianji(), getHeader());
					sheet.addCell(label);
					
				sheet.mergeCells(0, 12, 0, 13);
				label = new Label(0, 12, "时间节点", getHeader());
				sheet.addCell(label);

				label = new Label(1, 12, "年份", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(2, 12, 13, 12);
				if (0 == timeNode.getYear()) {
					label = new Label(2, 12, null, getHeader());
					sheet.addCell(label);
				} else {
					jxl.write.Number nb9 = new jxl.write.Number(2, 12, timeNode.getYear(), getNormalCell());
					sheet.addCell(nb9);
				}

				// for (int i = 1; i <= 12; i++) {
				// label = new Label(i + 1, 12, i + "月", getHeader());
				// sheet.addCell(label);
				// }
				label = new Label(1, 13, timeNode.getMonth() + "月", getHeader());
				sheet.addCell(label);

				// if(0==timeNode.getYear()){
				// label = new Label(1, 13, null,getHeader());
				// sheet.addCell(label);
				// }else{
				// jxl.write.Number nb9 = new jxl.write.Number(1, 13,
				// timeNode.getYear(),
				// getNormalCell());
				// sheet.addCell(nb9);
				// }
				sheet.mergeCells(2, 13, 13, 13);
				label = new Label(2, 13, timeNode.getDescription(), getHeader());
				sheet.addCell(label);

				// for (int i = 2; i <= 13; i++) {
				// if((timeNode.getMonth()+1)==i)
				// {
				// label = new Label(i, 13, timeNode.getDescription(),
				// getHeader());
				// sheet.addCell(label);
				// continue;
				// }
				//
				// label = new Label(i, 13, null, getHeader());
				// sheet.addCell(label);
				//
				// }

				sheet.mergeCells(0, 14, 0, 16);
				label = new Label(0, 14, "当前进展", getHeader());
				sheet.addCell(label);

				sheet.mergeCells(1, 14, 13, 16);
				label = new Label(1, 14, company.getDangqianjinzhan(), getHeader());
				sheet.addCell(label);

				wwb.write();
				wwb.close();
				os.close();
				return true;
			}
		} catch (Exception e) {
			System.out.println("---打印格式表出现异常---");
			e.printStackTrace();
			return false;
		}
	}

	public static WritableCellFormat getHeader() {
		WritableFont font = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD);
		WritableCellFormat format = new WritableCellFormat(font);
		try {
			format.setWrap(true);
			format.setAlignment(jxl.format.Alignment.CENTRE);
			format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	// public static WritableCellFormat getNewHeader() {
	// WritableFont font = new WritableFont(WritableFont.TIMES, 10,
	// WritableFont.BOLD);
	// WritableCellFormat format = new WritableCellFormat(font);
	// try {
	// format.setWrap(true);
	// format.setAlignment(jxl.format.Alignment.CENTRE);
	// format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
	// format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
	// } catch (WriteException e) {
	// e.printStackTrace();
	// }
	// return format;
	// }
	//

	@Override
	public boolean exportStatistic(String path, List<Company> companies, SelectedItems items) {
		try {
			String filePath = path;
			WritableWorkbook wwb = null;
			OutputStream os = null;
			os = new FileOutputStream(filePath);
			wwb = Workbook.createWorkbook(os);
			WritableSheet sheet = wwb.createSheet("企业信息统计表", 0);

			CellView cellView = new CellView();
			CellView cellView2 = new CellView();
			cellView2.setSize(12000);

			cellView.setAutosize(true);

			for (int i = 0; i < items.getItems().size(); i++) {
				if (("备注".equals(items.getItems().get(i))) || ("简介".equals(items.getItems().get(i)))
						|| ("当前进展".equals(items.getItems().get(i)))) {
					sheet.setColumnView(i, cellView2);
				} else {
					sheet.setColumnView(i, cellView);
				}
			}

			// for (int i = 0; i < items.getItems().size(); i++) {
			// sheet.setColumnView(i, cellView);
			// }

			sheet.setRowView(0, 540, false);
			for (int i = 1; i <= companies.size(); i++) {
				sheet.setRowView(i, 5 * 540, false);
			}

			Label label;
			// jxl.write.NumberFormat nf = new
			// jxl.write.NumberFormat("#,###.00");
			// jxl.write.WritableCellFormat wcf = new
			// jxl.write.WritableCellFormat(nf);
			// jxl.write.WritableCellFormat wcf = new
			// jxl.write.WritableCellFormat();
			// wcf.setAlignment(Alignment.CENTRE);
			// wcf.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);

			for (int i = 0; i < items.getItems().size(); i++) {
				// if(("备注".equals(items.getItems().get(i)))||("简介".equals(items.getItems().get(i)))||("当前进展".equals(items.getItems().get(i)))){
				// sheet.setColumnView(i, cellView2);
				// }
				label = new Label(i, 0, items.getItems().get(i), getHeader());
				sheet.addCell(label);
			}

			for (int i = 1; i <= companies.size(); i++) {
				for (int j = 0; j < items.getItems().size(); j++) {

					switch (items.getItems().get(j)) {
					case "企业名称":
						label = new Label(j, i, companies.get(i - 1).getQiyemingcheng(), getNormalCell());
						sheet.addCell(label);
						break;
					case "建设单位":
						label = new Label(j, i, companies.get(i - 1).getJianshedanwei(), getNormalCell());
						sheet.addCell(label);
						break;
					case "占地":
						label = new Label(j, i, companies.get(i - 1).getZhandi(), getNormalCell());
						sheet.addCell(label);
						break;
					case "税收":
						label = new Label(j, i, companies.get(i - 1).getShuishou(), getNormalCell());
						sheet.addCell(label);
						break;
					case "利润":
						label = new Label(j, i, companies.get(i - 1).getLirun(), getNormalCell());
						sheet.addCell(label);
						break;
					case "注册资本":
						label = new Label(j, i, companies.get(i - 1).getZhuceziben(), getNormalCell());
						sheet.addCell(label);
						break;
					case "总投资":
						label = new Label(j, i, companies.get(i - 1).getZongtouzi(), getNormalCell());
						sheet.addCell(label);
						break;
					case "年产值":
						label = new Label(j, i, companies.get(i - 1).getNianchanzhi(), getNormalCell());
						sheet.addCell(label);
						break;
					case "用工":
						label = new Label(j, i, companies.get(i - 1).getYonggong(), getNormalCell());
						sheet.addCell(label);
						break;
					case "包项目负责人":
						label = new Label(j, i, companies.get(i - 1).getBaoxiangmufuzeren(), getNormalCell());
						sheet.addCell(label);
						break;
					case "企业联系人":
						label = new Label(j, i, companies.get(i - 1).getQiyelianxiren(), getNormalCell());
						sheet.addCell(label);
						break;
					case "联系人电话":
						label = new Label(j, i, companies.get(i - 1).getLianxirendianhua(), getNormalCell());
						sheet.addCell(label);
						break;
					case "备注":
						// sheet.setColumnView(j, cellView2);
						label = new Label(j, i, companies.get(i - 1).getBeizhu(), getNormalCell());
						sheet.addCell(label);
						break;
					case "简介":
						// sheet.setColumnView(j, cellView2);
						label = new Label(j, i, companies.get(i - 1).getJianjie(), getNormalCell());
						sheet.addCell(label);
						break;
					case "注册":
						label = new Label(j, i, companies.get(i - 1).getZhuceshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "土地预审":
						label = new Label(j, i, companies.get(i - 1).getTudiyushenshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "备案":
						label = new Label(j, i, companies.get(i - 1).getBeianshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "环评":
						label = new Label(j, i, companies.get(i - 1).getHuanpingshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "土地出让合同":
						label = new Label(j, i, companies.get(i - 1).getTudichuranghetongshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "建设用地规划许可":
						label = new Label(j, i, companies.get(i - 1).getJiansheyongdixukeshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "建筑工程规划许可":
						label = new Label(j, i, companies.get(i - 1).getJianzhugongchengshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "施工许可":
						label = new Label(j, i, companies.get(i - 1).getShigongxukeshijian(), getNormalCell());
						sheet.addCell(label);
						break;
					case "完成投资":
						label = new Label(j, i, companies.get(i - 1).getWanchengtouzi(), getNormalCell());
						sheet.addCell(label);
						break;
					case "开工面积":
						label = new Label(j, i, companies.get(i - 1).getKaigongmianji(), getNormalCell());
						sheet.addCell(label);

						break;
					case "当前进展":
						// sheet.setColumnView(j, cellView2);
						label = new Label(j, i, companies.get(i - 1).getDangqianjinzhan(), getNormalCell());
						sheet.addCell(label);
						break;
					case "项目属性":
						String xmsx = "";
						for (String s : companies.get(i - 1).getXiangmushuxing()) {
							xmsx = xmsx.concat((s + " \n"));
						}
						label = new Label(j, i, xmsx, getNormalCell());
						sheet.addCell(label);
						break;
					case "企业分类":
						String qysx = "";
						for (String s : companies.get(i - 1).getQiyefenlei()) {
							qysx = qysx.concat((s + " \n"));
						}
						label = new Label(j, i, qysx, getNormalCell());
						sheet.addCell(label);
						break;

					default:
						break;
					}
				}
			}
			wwb.write();
			wwb.close();
			os.close();
			return true;
		} catch (Exception e) {
			System.out.println("---打印统计表出现异常---");
			e.printStackTrace();
			return false;
		}
	}

	public static WritableCellFormat getNormalCell() {
		WritableFont font = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD);
		WritableCellFormat format = new WritableCellFormat(font);
		try {
			format.setWrap(true);
			format.setAlignment(jxl.format.Alignment.CENTRE);
			format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return format;
	}

	// public static void main(String[] args) {
	//
	// ExportabilityImp ex = new ExportabilityImp();
	// ex.exportSinglePage("D:\\空白格表handsome.xlsx", null, null);
	// }
}
